<html>
<head>
    <meta charset="UTF-8">
    <title>合同列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" />
    <link rel="stylesheet" href="../../css/bass.css" />
    <style>
        .layui-form{
            width:35%;
        }
        .layui-input{
            width: 100% !important;
        }
        .layui-form-label{
        	padding-right: 10px;
        }
    </style>
</head>

<body>
<div class="body">
    <header class="layui-nav" id="headerTop"></header>
    <div class="left_muen" id="left_menu"></div>
    <div class="content_body">

        <!--标题栏-->
        <p class="content_title">气量管理 &nbsp;&nbsp;>&nbsp;&nbsp;合同日计划&nbsp;&nbsp;>&nbsp;&nbsp;新增计划</p>
        <!--标题栏-->

        <form class="layui-form mt20">
            <div class="layui-form-item">
                <label class="layui-form-label">组织名称</label>
                <div class="layui-input-block">
                    <input type="text" name="contractName" lay-verify="required" autocomplete="off" placeholder="请输入公司名称" class="layui-input w30">
                </div>
            </div>
            <div class="layui-form-item">
                <!--<div class="layui-inline">-->
                    <label class="layui-form-label">合同名称</label>
                    <div class="layui-input-block">
                        <select name="contractId" lay-verify="required" lay-search="" id="contractName" >
                            <option value="0">请选择合同</option>
                        </select>
                    </div>
                <!--</div>-->
            </div>
            <div class="layui-form-item">
            <!--<div class="layui-inline">-->
                <label class="layui-form-label">站点</label>
                <div class="layui-input-block">
                    <select name="siteId" lay-verify="required" lay-search="" id="siteName">
                        <option value="0">请选择站点</option>
                    </select>
                </div>
            <!--</div>-->
        </div>
            <div class="layui-form-item">
                <!--<div class="layui-inline">-->
                    <label class="layui-form-label">单位</label>
                    <div class="layui-input-block">
                        <select name="unit" lay-verify="required" lay-search="">
                            <option value="">请选择单位</option>
                            <option value="0">标方</option>
                            <option value="1">吉焦</option>
                            <option value="2">方</option>
                        </select>
                    </div>
                <!--</div>-->
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">预测日指定计划</label>
                <div class="layui-input-block">
                    <input type="text" name="forecastPlanVal" lay-verify="required|number" placeholder="请输入合同名称" autocomplete="off" class="layui-input w30">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">日指定计划</label>
                <div class="layui-input-block">
                    <input type="text" name="planVal" lay-verify="required|number" placeholder="请输入日指定计划" autocomplete="off" class="layui-input w30">
                </div>
            </div>
            <div class="layui-form-item">
                <!--<div class="layui-inline">-->
                    <label class="layui-form-label">是否上报</label>
                    <div class="layui-input-block">
                        <select name="status" lay-verify="required" lay-search="">
                            <option value="0">否</option>
                            <option value="1">是</option>
                        </select>
                    </div>
                <!--</div>-->
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="planDesc" lay-verify="" placeholder="请输入描述" autocomplete="off" class="layui-input w30">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-btn" lay-submit="" lay-filter="submitFilter">立即提交</div>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="../../js/common/jquery-1.11.3.min.js"></script>
<script src="../../layui/layui.js"></script>
<script src="../../js/common/navList.js"></script>
<script src="../../js/common/ajax.js"></script>
<script>
        var user =  JSON.parse(window.sessionStorage.getItem('user'));
        user.userCompanyAllTitle = !user.msg.userCompanyAllTitle?"":user.msg.userCompanyAllTitle;
        ajaxGet({
            url:'site/getListNoPage?&userCompanyAllTitle='+user.userCompanyAllTitle,
            successFull: function(res) {
                if(res.list.length != 0){
                    $.each(res.list,function(i,item){
                        $("#siteName").append('<option value="'+item.id+'">'+item.siteName+'</option>');
                    })
                }
            },
            errCallBack: function(res) {}
        });
	ajaxGet({
        	url:'contract/getListAll?&userCompanyAllTitle='+user.userCompanyAllTitle,
        	successFull: function(res) {
        		console.log(res)
        		console.log(1)
                if(res.list.length != 0){
                    $.each(res.list,function(i,item){
                        console.log(item)
                        $("#contractName").append('<option value="'+item.id+'">'+item.siteName+'</option>');
                    })
                }
            },
            errCallBack: function(res) {
            	console.log(res)
            	if(res.length != 0){
                    $.each(res,function(i,item){
                        console.log(item)
                        $("#contractName").append('<option value="'+item.id+'">'+item.contractName+'</option>');
                    })
                }
            }
       });
    layui.use(['form', 'layedit'], function() {
        var form = layui.form,layer = layui.layer,layedit = layui.layedit;
        //监听提交
        form.on('submit(submitFilter)', function(data) {
            console.log(data.field)
            ajaxPost({
                url: 'contractdayplan/add?&userCompanyAllTitle='+user.userCompanyAllTitle,
                data: {
                    contractId: data.field.contractId,
                    organization: data.field.organization,
                    siteId: data.field.siteId,
                    unit: data.field.unit,
                    forecastPlanVal: data.field.forecastPlanVal,
                    planVal: data.field.planVal,
                    status: data.field.status,
                    planDesc: data.field.planDesc,
                    contractName: $("#contractName option:selected").text(),
                    siteName:$("#siteName option:selected").text(),
                    userCompanyAllTitle:user.userCompanyAllTitle
                },
                successFull: function(res) {
                    console.log(res)
                    layer.msg('添加成功', {
                        icon: 6
                    });
                      window.location.href = "./contractDayUser.html?pos=4&childPos=4";
                },
                errCallBack: function(res) {
                    layer.msg(res.msg, {
                        icon: 6
                    });
                }
            })
        });
    });
</script>
</body>
</html>